package com.heima.leadnews.article.controller;

import com.heima.leadnews.article.service.ApArticleService;
import com.heima.model.article.dto.ApArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {

    @Autowired
    private ApArticleService apArticleService;
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ApArticleHomeDto dto){
        //1.接收参数
        //2.调用service
        //3.响应结果
        return apArticleService.load(dto.getSize(),dto.getTag());
    }

    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ApArticleHomeDto dto){
        //1.接收参数
        //2.调用service
        //3.响应结果
        return apArticleService.loadmore(dto.getSize(),dto.getTag(),dto.getMinBehotTime());
    }

    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ApArticleHomeDto dto){
        //1.接收参数
        //2.调用service
        //3.响应结果
        return apArticleService.loadnew(dto.getSize(),dto.getTag(),dto.getMaxBehotTime());
    }

}
